package cn.xiaomagege.platform.config;

import cn.xiaomagege.platform.template.directive.*;
import freemarker.template.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FreemarkerConfig {
    
    @Autowired
    private Configuration configuration;
    
    @Autowired
    private SystemDirective systemDirective;
    
    @Autowired
    private ArticleDirective articleDirective;
    
    @Autowired
    private IndexArticleDirective indexArticleDirective;
    
    @Autowired
    private ChannelDirective channelDirective;
    
    @Autowired
    private ParentChannelListDirective parentChannelListDirective;
    
    @Autowired
    private ArticleClickTempletModel articleClickTempletModel;
    
    @Autowired
    private SysUserTempletModel sysUserTempletModel;
    
    @Autowired
    private TagsTempletModel tagsTempletModel;
    
    @Autowired
    private NewCommentArticleTempletModel newCommentArticleTempletModel;
    
    @Autowired
    private LookLikeArticlesTempletModel lookLikeArticlesTempletModel;
    
    @Autowired
    private CommentNumberTempletModel commentNumberTempletModel;
    
    @Bean
    public void setSharedVariable() {
        // 注册自定义指令
        configuration.setSharedVariable("system", systemDirective);
        configuration.setSharedVariable("article", articleDirective);
        configuration.setSharedVariable("indexArticle", indexArticleDirective);
        configuration.setSharedVariable("channel", channelDirective);
        configuration.setSharedVariable("parentChannel", parentChannelListDirective);
        configuration.setSharedVariable("articleClick", articleClickTempletModel);
        configuration.setSharedVariable("sysUser", sysUserTempletModel);
        configuration.setSharedVariable("tags", tagsTempletModel);
        configuration.setSharedVariable("newCommentArticle", newCommentArticleTempletModel);
        configuration.setSharedVariable("lookLikeArticles", lookLikeArticlesTempletModel);
        configuration.setSharedVariable("commentNumber", commentNumberTempletModel);
    }
}